/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package org.apache.skywalking.oap.server.core.analysis;

import java.lang.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;

/**
 * @author peng-yongsheng
 */
// OAP 会在初始化时扫描 @Stream 注解，并根据其中的信息初始化对应的 Model 对象。
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Stream {

    // 对应的索引名称。这里的 ServiceInventory 指定的就是 service_inventory
    // 索引，如果是 Metrics 等与时间相关数据，则 name 只是对应 ES 索引的前缀。
    String name();

    // ES 的 Document ID 或 表主键
    int scopeId();

    // 每个 StorageData 实现类都关联了一个 StorageBuilder 实现类（多数为 StorageData 实现的内部类），
    // 两者就是通过该字段进行关联的。StorageBuilder 负责 StorageData 对象与 Map<String，Object> 之间
    // 的转换。ServiceInventory 关联的就是其自身的内部类 —— ServiceInventory.Builder。
    Class<? extends StorageBuilder> builder();

    // 含义是收到该类型的数据时会交给 processor 指定的处理器进行处理。processor 指定的处理器都是 StreamProcessor 类型的。
    Class<? extends StreamProcessor> processor();
}
